<?php
/**
 * 活动奖励计算
 * Class ActivityReward
 */
namespace app\common\service;

use app\common\model\activity\ActivityProfitModel;
use app\common\model\activity\InviteFriendsActivitiesModel;

class ActivityReward
{
	/**
	 * 活动编号
	 * @var int
	 */
	var $active_id;
	
	/**
	 * 三级用户编号
	 * @var int
	 */
	var $user_id;
	
	/**
	 * 二级用户编号
	 * @var int
	 */
	var $user_parent_id;
	
	/**
	 * 一级用户编号
	 * @var int
	 */
	var $user_grand_id;
	
	/**
	 * 用户级别和用户编号列表
	 * @var array
	 */
	var $user_list = [
			0=>0,1=>0,2=>0
	];
	
	/**
	 * 活动信息
	 * @var array
	 */
	var $active_info;
	
	
	//======================================================================奖励基数==============================================================================//
	
	/**
	 * 邀请登陆奖励 0=>自己 1=>上级 2=>上上级别
	 * @var string
	 */
	var $loginRewardBase = [
			0 => 0,  // 首次评论奖励
			1 => 0,	 // 一级邀请	
			2 => 0   // 二级邀请
	];
	
	/**
	 * 评论 奖励基数
	 * @var integer
	 */
	var $commentRewardBase = 0;
	
	/**
	 * 被评论 奖励基数(下级向上级奖励)
	 * @var array
	 */
	var $reCommentRewardBase = [
			0 => 0, 1 => 0
	];
	
	/**
	 * 点赞 奖励基数
	 * @var integer
	 */
	var $upRewardBase = 0;
	
	/**
	 * 被点赞 奖励基数
	 * @var array
	 */
	var $reUpRewardBase = [
			0 => 0, 1 => 0
	];
	
	/**
	 * 分享 奖励基数
	 * @var integer
	 */
	var $shareRewardBase = 0;
	
	/**
	 * 被分享 奖励基数
	 * @var array
	 */
	var $reShareRewardBase = [
			0 => 0, 1 => 0
	];
	
	//======================================================================奖励限制(每日)==============================================================================//
	
	/**
	 * 评论奖励每天限制次数
	 * @var integer
	 */
	const commentRewardTimesLimit = 10;
	
	/**
	 * 被评论奖励每天限制次数
	 * @var array
	 */
	const reCommentRewardTimesLimit = [
			0 => 5,
			1 => 5,
	];
	
	/**
	 * 点赞奖励每天限制次数
	 * @var integer
	 */
	const upRewardTimesLimit = 10;
	
	/**
	 * 被点赞奖励每天限制次数
	 * @var array
	 */
	const reUpRewardTimesLimit = [
			0 => 5,
			1 => 5
	];
	
	/**
	 * 分享奖励每天限制次数
	 * @var integer
	 */
	const shareRewardTimesLImit = 10;
	
	/**
	 * 被分享奖励每天限制次数
	 * @var array
	 */
	const reShareRewardTimesLimit = [
			0 => 5,
			1 => 5
	];
	
	//======================================================================奖励权重系数配置==============================================================================//
	
	/**
	 * 评论条数(发起评论)奖励权重系数
	 * @var array
	 */
	const commentRewardWeightParam = [
			// 发起评论条数
			array(
					'num' => [0,1],
					'param' => 1,
			),
			array(
					'num' => [2,15],
					'param' => 1.2,
			),
			array(
					'num' => [16,99999999],
					'param' => 1.4,
			),
	];
	
	/**
	 * 邀请发评论的人数奖励权重系数(下级向上级奖励)
	 * @var array
	 */
	const inviteCommentRewardWeightParam = [
			//一级邀请发评论的人数, 上级奖励权重系数
			1=> array(
					array(
							'num' => [0,1],
							'param' => 1,
					),
					array(
							'num' => [2,5],
							'param' => 1.2,
					),
					array(
							'num' => [6,15],
							'param' => 1.4,
					),
					array(
							'num' => [16,99999999],
							'param' => 1.6,
					),
			),
			//二级邀请发评论的人数, 上级的上级奖励权重系数
			2=> array(
					array(
							'num' => [0,5],
							'param' => 1,
					),
					array(
							'num' => [6,15],
							'param' => 1.2,
					),
					array(
							'num' => [16,99999999],
							'param' => 1.4,
					),
			),
	];
	
	/**
	 * 被评论人数权重系数(下级向上级奖励)
	 * @var array
	 */
	const reCommentRewardWeightParam = [
			// 一级被评论条数
			1=> array(
					array(
							'num' => [0,15],
							'param' => 1,
					),
					array(
							'num' => [16, 99999999],
							'param' => 1.2,
					),
			),
			// 二级被评论条数
			2=> array(
					array(
							'num' => [0,15],
							'param' => 1,
					),
					array(
							'num' => [16, 99999999],
							'param' => 1.2,
					),
			),
	];
	
	/**
	 * 点赞次数(发起点赞)奖励权重系数
	 * @var array
	 */
	const upRewardWeightParam = [
			array(
					'num' => [0,10],
					'param' => 1,
			),
			array(
					'num' => [11,30],
					'param' => 1.2,
			),
			array(
					'num' => [31,99999999],
					'param' => 1.4,
			),
	];
	
	/**
	 * 被点赞次数权重系数(下级向上级奖励)
	 * @var array
	 */
	const reUpRewardWeightParam = [
			1 => array(
					array(
							'num' => [0,10],
							'param' => 1,
					),
					array(
							'num' => [11,99999999],
							'param' => 1.2,
					),
			),
			2 => array(
					array(
							'num' => [0,10],
							'param' => 1,
					),
					array(
							'num' => [11,99999999],
							'param' => 1.2,
					),
			),
	];
	
	/**
	 * 分享次数(发起分享)奖励权重系数
	 * @var array
	 */
	const shareRewardWeightParam = [
			array(
					'num' => [0,10],
					'param' => 1,
			),
			array(
					'num' => [11,30],
					'param' => 1.2,
			),
			array(
					'num' => [31,99999999],
					'param' => 1.4,
			),
	];
	
	/**
	 * 被分享次数权重系数(下级向上级奖励)
	 * @var array
	 */
	const reShareRewardWeightParam = [
			1 => array(
					array(
							'num' => [0,10],
							'param' => 1,
					),
					array(
							'num' => [11,99999999],
							'param' => 1.2,
					),
			),
			2 => array(
					array(
							'num' => [0,10],
							'param' => 1,
					),
					array(
							'num' => [11,99999999],
							'param' => 1.2,
					),
			),
	];
	
	
	/**
	 * 构造方法
	 * @param int $active_id	活动编号
	 * @param int $user_id		三级用户编号
	 * @param int $user_parent_id	二级用户编号
	 * @param int $user_grand_id	一级用户编号
	 */
	public function __construct( $active_id, $user_id, $user_parent_id = 0 , $user_grand_id = 0 ) {
		// 初始化赋值
		$this->active_id = $active_id;
		$this->user_id = $user_id;
		$this->user_parent_id = $user_parent_id;
		$this->user_grand_id = $user_grand_id;
		$this->user_list[0] = $user_id;
		if ( $user_parent_id ) $this->user_list[1] = $user_parent_id ;
		if ( $user_grand_id ) $this->user_list[2] = $user_grand_id ;
		// 获取邀请好友活动信息
		$this->active_info = $this->getActiveInfo();
		// 初始化奖励基数
		$this->initRewardBase();
	}
	
	//======================================================================活动相关================================================================================//
	
	/**
	 * 获取活动信息
	 */
	private function getActiveInfo() {
		// 活动模型
		$model = InviteFriendsActivitiesModel::getInstance();
		// 活动信息
		$this->active_info = $model->get_data_by_id($this->active_id);
		return $this->active_info;
	}
	
	/**
	 * 初始化奖励基数
	 */
	private function initRewardBase() {
		// 邀请奖励
		$login_reward = $this->active_info['login_reward'];
		$invite_reward = $this->active_info['invite_reward'];
		$login_grandsire_reward = $this->active_info['login_grandsire_reward'];
		$this->loginRewardBase[0] = $login_reward; // 首次评论奖励
		$this->loginRewardBase[1] = $invite_reward;
		$this->loginRewardBase[2] = $login_grandsire_reward;
		
		// 评论奖励
		$comment_reward = $this->active_info['comment_reward'];
		// 被评论奖励
		$comment_passive_reward = $this->active_info['comment_passive_reward'];
		// 被评论父级奖励
		$comment_parent_reward = $this->active_info['comment_parent_reward'];
		$this->commentRewardBase = $comment_reward;
		$this->reCommentRewardBase[0] = $comment_passive_reward;
		$this->reCommentRewardBase[1] = $comment_parent_reward;
		
		// 点赞奖励
		$up_reward = $this->active_info['up_reward'];
		// 被点赞奖励
		$up_passive_reward = $this->active_info['up_passive_reward'];
		// 被点赞父级奖励
		$up_parent_reward = $this->active_info['up_parent_reward'];
		$this->upRewardBase = $up_reward;
		$this->reUpRewardBase[0] = $up_passive_reward;
		$this->reUpRewardBase[1] = $up_parent_reward;
		
		// 分享奖励
		$share_reward = $this->active_info['share_reward'];
		// 被分享奖励
		$share_passive_reward = $this->active_info['share_passive_reward'];
		// 被分享父级奖励
		$share_parent_reward = $this->active_info['share_parent_reward'];
		$this->shareRewardBase = $share_reward;
		$this->reShareRewardBase[0] = $share_passive_reward;
		$this->reShareRewardBase[1] = $share_parent_reward;
	}
	
	/**
	 * 获取用户今日奖励次数
	 * @param string $profitType
	 * @return array
	 */
	private function getUserTodayRewardNum( $profitType ) {
		static $userRewardNum=[];
		if ( isset( $userRewardNum[$profitType] ) ) return $userRewardNum[$profitType];
		$startDateTime=time();
		$endDateTime = date( "Y-m-d 00:00:00", $startDateTime+86400 );
		$startDateTime = date( "Y-m-d 00:00:00", $startDateTime );
		$model = ActivityProfitModel::getInstance();
		$userList = [ $this->user_id=>0 ];
		if ( $this->user_parent_id ) $userList[$this->user_parent_id] = 0 ;
		if ( $this->user_grand_id ) $userList[$this->user_grand_id] = 0;
		// 查询条件
		$map = [
				'activity_id' => $this->active_id,
				'user_id' => array('in', array_keys($userList)),
				'type' => ActivityProfitModel::getConstant($profitType),
				'create_time' => array( 'between', array( $startDateTime, $endDateTime ) ),
		];
		// 获取数据
		$countList = $model->field( "user_id, type, activity_id, count(*) as count" )->where($map)->group("`user_id`,`type`,`activity_id`")->select();
		if ( $countList ) {
			foreach ( $countList as $v ) {
				$userList[$v['user_id']] = $v['count'];
			}
		}
		// 赋值静态变量
		$userRewardNum[$profitType] = $userList;
		return $userList;
	}
	
	/**
	 * 获取用户奖励次数
	 * @param string $profitType
	 * @return array
	 */
	private function getUserRewardNum( $profitType ) {
		static $userRewardNum;
		if ( isset( $userRewardNum[$profitType] ) ) return $userRewardNum[$profitType];
		$model = ActivityProfitModel::getInstance();
		$userList = [ $this->user_id=>0 ];
		if ( $this->user_parent_id ) $userList[$this->user_parent_id] = 0 ;
		if ( $this->user_grand_id ) $userList[$this->user_grand_id] = 0;
		$map = [
				"type" => ActivityProfitModel::getConstant($profitType),
				"user_id" => array('in', array_keys($userList)),
				"activity_id" => $this->active_id,
		];
		// 获取数据
		$countList = $model->field( "user_id, type, activity_id, count(*) as count" )->where($map)->group("`user_id`,`type`,`activity_id`")->select();
		if ( $countList ) {
			foreach ( $countList as $v ) {
				$userList[$v['user_id']] = $v['count'];
			}
		}
		
		// 赋值静态变量
		$userRewardNum[$profitType] = $userList;
		return $userList;
	}
	
	/**
	 * 获取实际奖励数
	 * @param string $profitType
	 * @param int 	$numCount
	 */
	private function getActualReward( $profitType, $numCount ) {
		$reward = 0;
		switch ( $profitType ) {
			case "PROFIT_TYPE_INVITE" :
				// 上级级邀请权重基数
				$inviteWeightParam = self::inviteCommentRewardWeightParam[1];
				$param = $this->checkRewardCount($numCount, $inviteWeightParam);
				$reward = bcmul($this->loginRewardBase[1], $param, 4);
				break;
			case "PROFIT_TYPE_TWO_INVITE":
				// 上上级邀请权重基数
				$inviteWeightParam = self::inviteCommentRewardWeightParam[2];
				$param = $this->checkRewardCount($numCount, $inviteWeightParam);
				$reward = bcmul($this->loginRewardBase[2], $param, 4);
				break;
			case "PROFIT_TYPE_COMMENT":
				// 自己发起评论权重基数
				$commentWeightParam = self::commentRewardWeightParam;
				$param = $this->checkRewardCount($numCount, $commentWeightParam);
				$reward = bcmul($this->commentRewardBase, $param, 4);
				break;
			case "PROFIT_TYPE_COMMENT_PASSIVE":
				// 被评论权重基数
				$reCommentWeightParam = self::reCommentRewardWeightParam[1];
				$param = $this->checkRewardCount($numCount, $reCommentWeightParam);
				$reward = bcmul($this->reCommentRewardBase[0], $param, 4);
				break;
			case "PROFIT_TYPE_COMMENT_PARENT":
				// 被评论上级权重基数
				$reCommentWeightParam = self::reCommentRewardWeightParam[2];
				$param = $this->checkRewardCount($numCount, $reCommentWeightParam);
				$reward = bcmul($this->reCommentRewardBase[1], $param, 4);
				break;
			case "PROFIT_TYPE_UP" :
				// 自己发起点赞权重基数
				$upWeightParam = self::upRewardWeightParam;
				$param = $this->checkRewardCount($numCount, $upWeightParam);
				$reward = bcmul($this->upRewardBase, $param, 4);
				break;
			case "PROFIT_TYPE_UP_PASSIVE" :
				// 被点赞权重基数
				$reUpWeightParam = self::reUpRewardWeightParam[1];
				$param = $this->checkRewardCount($numCount, $reUpWeightParam);
				$reward = bcmul($this->reUpRewardBase[0], $param, 4);
				break;
			case "PROFIT_TYPE_UP_PARENT" :
				// 被点赞上级权重基数
				$reUpWeightParam = self::reUpRewardWeightParam[2];
				$param = $this->checkRewardCount($numCount, $reUpWeightParam);
				$reward = bcmul($this->reUpRewardBase[1], $param, 4);
				break;
			case "PROFIT_TYPE_SHARE":
				// 自己发起分享权重基数
				$shareWeightParam = self::shareRewardWeightParam;
				$param = $this->checkRewardCount($numCount, $shareWeightParam);
				$reward = bcmul($this->shareRewardBase, $param, 4);
				break;
			case "PROFIT_TYPE_SHARE_PASSIVE":
				// 被分享权重基数
				$reShareWeightParam = self::reShareRewardWeightParam[1];
				$param = $this->checkRewardCount($numCount, $reShareWeightParam);
				$reward = bcmul($this->reShareRewardBase[0], $param, 4);
				break;
			case "PROFIT_TYPE_SHARE_PARENT":
				// 被分享上级权重基数
				$reShareWeightParam = self::reShareRewardWeightParam[2];
				$param = $this->checkRewardCount($numCount, $reShareWeightParam);
				$reward = bcmul($this->reShareRewardBase[1], $param, 4);
				break;
		}
		
		return $reward;
	}
	
	/**
	 * 判断奖励数量在那个权重系数单元, 返回权重系数
	 * @param int 	$numCount		奖励数量
	 * @param array $weightParam	权重系数单元数组
	 * @return int
	 */
	private function checkRewardCount( $numCount, array $weightParam ) {
		//$message = "numCount:$numCount";
		//Log::write($message);
		$numCount = (int) $numCount+1;
		$param = 0;
		foreach ( $weightParam as $v ) {
			$num = $v['num'];
			list($min, $max) = $num;
			if ( $min<=$numCount && $numCount<=$max ) {
				$param = $v['param'];
				//$message = "Param:$param";
				//Log::write($message);
				break;
			}
		}
		return $param;
	}
	
	//======================================================================分销奖励计算================================================================================//
	
	/**
	 * 获取邀请奖励
	 * @return array
	 */
	public function getInviteReward() {
		// 获取上上级用户奖励次数
		$grandUserRewardVal = 0;
		if ( $this->user_grand_id ) {
			$profitType = "PROFIT_TYPE_TWO_INVITE";
			$oneUserRewardNum = $this->getUserRewardNum($profitType);
			// 上上级级用户奖励
			$grandUserRewardNum = $oneUserRewardNum[$this->user_grand_id];
			$grandUserRewardVal = $this->getActualReward($profitType, $grandUserRewardNum);
		}
		// 获取上级用户奖励次数
		$parentUserRewardVal = 0;
		if ( $this->user_parent_id ) {
			$profitType = "PROFIT_TYPE_INVITE";
			$twoUserRewardNum = $this->getUserRewardNum($profitType);
			// 上级用户奖励
			$parentUserRewardNum = $twoUserRewardNum[$this->user_parent_id];
			$parentUserRewardVal = $this->getActualReward($profitType, $parentUserRewardNum);
		}
		// 用户自己奖励
		$userRewardVal = $this->loginRewardBase[0];
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => $parentUserRewardVal,
				$this->user_grand_id => $grandUserRewardVal,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取评论奖励
	 * @return array
	 */
	public function getCommentReward() {
		$profitType = "PROFIT_TYPE_COMMENT";
		// 获取今日评论条数
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($profitType);
		$userTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $userTodayRewardNum < self::commentRewardTimesLimit ){
			// 获取总评论次数
			$allUserRewardNum = $this->getUserRewardNum($profitType);
			// 用户自己评论次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户获得实际奖励
			$userRewardVal = $this->getActualReward($profitType, $userRewardNum);
		}
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => 0,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取被评论奖励
	 * @return array
	 */
	public function getReCommentReward() {
		// 获取自己今日被评论数
		$selfProfitType = "PROFIT_TYPE_COMMENT_PASSIVE";
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($selfProfitType);
		$selfUserTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $selfUserTodayRewardNum < self::reCommentRewardTimesLimit[0] ){
			// 获取被评论总次数
			$allUserRewardNum = $this->getUserRewardNum($selfProfitType);
			// 用户自己被评论次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户自己获得实际奖励
			$userRewardVal = $this->getActualReward($selfProfitType, $userRewardNum);
		}
		
		// 获取上级今日被评论数
		$parentRewardVal = 0;
		if ( $this->user_parent_id ) {
			$parentProfitType = "PROFIT_TYPE_COMMENT_PARENT";
			$allUserTodayRewardNum = $this->getUserTodayRewardNum($parentProfitType);
			$parentUserTodayRewardNum = $allUserTodayRewardNum[$this->user_parent_id];
			if ( $parentUserTodayRewardNum < self::reCommentRewardTimesLimit[1] ){
				// 获取被评论总次数
				$allUserRewardNum = $this->getUserRewardNum($parentProfitType);
				// 用户上级被评论次数
				$parentRewardNum = $allUserRewardNum[$this->user_parent_id];
				// 用户上级获得实际奖励
				$parentRewardVal = $this->getActualReward($parentProfitType, $parentRewardNum);
			}
		}
		
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => $parentRewardVal,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取点赞奖励
	 * @return array
	 */
	public function getUpReward() {
		$profitType = "PROFIT_TYPE_UP";
		// 获取今日点赞条数
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($profitType);
		$userTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $userTodayRewardNum < self::upRewardTimesLimit ){
			// 获取总点赞数
			$allUserRewardNum = $this->getUserRewardNum($profitType);
			// 用户自己点赞次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户获得实际奖励
			$userRewardVal = $this->getActualReward($profitType, $userRewardNum);
		}
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => 0,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取被点赞奖励
	 * @return array
	 */
	public function getReUpReward() {
		// 获取自己今日被点赞数
		$selfProfitType = "PROFIT_TYPE_UP_PASSIVE";
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($selfProfitType);
		$selfUserTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $selfUserTodayRewardNum < self::reUpRewardTimesLimit[0] ){
			// 获取被点赞总次数
			$allUserRewardNum = $this->getUserRewardNum($selfProfitType);
			// 用户自己被点赞次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户自己获得实际奖励
			$userRewardVal = $this->getActualReward($selfProfitType, $userRewardNum);
		}
		
		// 获取上级今日被点赞数
		$parentRewardVal = 0;
		if ( $this->user_parent_id ) {
			$parentProfitType = "PROFIT_TYPE_UP_PARENT";
			$allUserTodayRewardNum = $this->getUserTodayRewardNum($parentProfitType);
			$parentUserTodayRewardNum = $allUserTodayRewardNum[$this->user_parent_id];
			if ( $parentUserTodayRewardNum < self::reUpRewardTimesLimit[1] ){
				// 获取被点赞总次数
				$allUserRewardNum = $this->getUserRewardNum($parentProfitType);
				// 用户上级被点赞次数
				$parentRewardNum = $allUserRewardNum[$this->user_parent_id];
				// 用户上级获得实际奖励
				$parentRewardVal = $this->getActualReward($parentProfitType, $parentRewardNum);
			}
		}
		
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => $parentRewardVal,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取分享奖励
	 * @return array
	 */
	public function getShareReward() {
		$profitType = "PROFIT_TYPE_SHARE";
		// 获取今日分享数
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($profitType);
		$userTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $userTodayRewardNum < self::shareRewardTimesLImit ){
			// 获取总分享数
			$allUserRewardNum = $this->getUserRewardNum($profitType);
			// 用户自己分享次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户获得实际奖励
			$userRewardVal = $this->getActualReward($profitType, $userRewardNum);
		}
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => 0,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	/**
	 * 获取被分享奖励
	 * @return array
	 */
	public function getReShareReward() {
		// 获取自己今日被分享数
		$selfProfitType = "PROFIT_TYPE_SHARE_PASSIVE";
		$allUserTodayRewardNum = $this->getUserTodayRewardNum($selfProfitType);
		$selfUserTodayRewardNum = $allUserTodayRewardNum[$this->user_id];
		// 判断是否超过每日限制
		$userRewardVal = 0;
		if ( $selfUserTodayRewardNum < self::reShareRewardTimesLimit[0] ){
			// 获取被分享总次数
			$allUserRewardNum = $this->getUserRewardNum($selfProfitType);
			// 用户自己被分享次数
			$userRewardNum = $allUserRewardNum[$this->user_id];
			// 用户自己获得实际奖励
			$userRewardVal = $this->getActualReward($selfProfitType, $userRewardNum);
		}
		
		// 获取上级今日被分享数
		$parentRewardVal = 0;
		if ( $this->user_parent_id ) {
			$parentProfitType = "PROFIT_TYPE_SHARE_PARENT";
			$allUserTodayRewardNum = $this->getUserTodayRewardNum($parentProfitType);
			$parentUserTodayRewardNum = $allUserTodayRewardNum[$this->user_parent_id];
			if ( $parentUserTodayRewardNum < self::reShareRewardTimesLimit[1] ){
				// 获取被分享总次数
				$allUserRewardNum = $this->getUserRewardNum($parentProfitType);
				// 用户上级被分享次数
				$parentRewardNum = $allUserRewardNum[$this->user_parent_id];
				// 用户上级获得实际奖励
				$parentRewardVal = $this->getActualReward($parentProfitType, $parentRewardNum);
			}
		}
		
		$userRewardList = [
				$this->user_id => $userRewardVal,
				$this->user_parent_id => $parentRewardVal,
				$this->user_grand_id => 0,
		];
		return $userRewardList;
	}
	
	
}